package shop.local.ui.gui;

import javax.swing.JPanel;
import net.miginfocom.swing.MigLayout;
import javax.swing.JLabel;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;

public class NaviPanel extends JPanel {
	private JTextField txtSuchen;
	private MainWindow main;
	/**
	 * Create the panel.
	 */
	public NaviPanel(MainWindow window) {
		this.main = window;
		setLayout(new MigLayout("", "[grow]", "[]"));
		
		txtSuchen = new JTextField();
		txtSuchen.addFocusListener(new FocusAdapter() {
			@Override
			public void focusGained(FocusEvent f) {
				JTextField text = (JTextField) f.getComponent();
				text.setText("");
			}
		});
		txtSuchen.setText("Etwas suchen...");
		add(txtSuchen, "flowx,cell 0 0,growx");
		txtSuchen.setColumns(10);
		
		JButton btnLos = new JButton("Los!");
		btnLos.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				main.suche(txtSuchen.getText());
			}
		});
		add(btnLos, "cell 0 0");
	}

}
